<?php
class CmsPostViewControl extends CmsBaseControl
{
    public function Render()
    {
        $id = RequestHandler::Get('post_id');
        $post = CmsPostModel::GetInstance()->FindById($id);
        $post['authorName'] = self::GetAuthorName($post['createdby']);
        $comment = new CmsCommentControl($id);

        $controller = RequestHandler::GetInstance()->controller;
        $controller->SetTitle($post['title']);
        $controller->SetMetaKeywords('');
        $controller->SetMetaDescription(strip_tags($post['excerpt']));

        $this->Replace($post);
        $this->Replace('comment', $comment->Render());
        return parent::Render();
    }

    public static function GetAuthorName($userId)
    {
        return CmsUserModel::GetInstance()->FindScalarById($userId, 'fullname');
    }
}
?>